//用户接口
import { instances } from 'element-plus/es/components/message/src/instance.mjs';
import instance from '../utils/request.js'

// 用户登录
export const userLoginService = ({ phone, password }) => {
    // console.log("用户登录")
    return instance.post('/user/login', { phone, password })
}

// 用户忘记密码
export const forgetPassword = ({ phone, captcha, password, rePassword, }) => {
    return instance.put("/user/forgetPassword", { phone, captcha, password, rePassword, })
}

// 用户获取验证码
export const getCaptcha = (phone) => {
    return instance.get(`/user/captcha?phone=${phone}`)
}


// 用户注册
export const postRegisterService = ({ phone, captcha, password, rePassword, }) => {
    // console.log("注册用户")
    return instance.post("/user/register", { phone, captcha, password, rePassword, })
}


// 用户修改密码

export const modifyPassword = ({ phone, captcha, password, rePassword, }) => {
    return instance.put('/user/modifyPassword',{ phone, captcha, password, rePassword, })
}

// 获取用户信息
export const getUserInfo = (token) => {
    return instance.get('/user/getUserInfo', {
        headers: {
            'Authorization': token
        }
    })
}

// 用户修改手机号
export const modifyPhone = ({ oldPhone, newPhone, oldCaptcha, newCaptcha }) => {
    return instance.put('/user/modifyPhone',{ oldPhone, newPhone, oldCaptcha, newCaptcha })
}

// 用户修改用户名
export const modifyUserName = ({ username, gender }) => {
    return instance.put('/user/modifyUserName', { username, gender })
}

// 用户退出登录
export const userLogout = () => {
    return instance.put('/user/logout')
}